<?php
class AdminBaseAction extends Action
{
    function __construct()
    {
        parent::__construct();

        //后台管理菜单
        $menu = M('admin_menu');
        $items = $menu->cache(true)->where('parent_id=0')->order('display_index')->select();
        $items[0]['selected'] = true;
        $thismenu = null;
        foreach ($items as &$item) {
            if ($item['action_class_name'] . 'Action' == get_class($this)) {
                $item['selected'] = true;
                $thismenu = $item;
            } else
                $item['selected'] = false;
        }
        $this->assign('_gxcms_admin_menu', $items); //后台主菜单


        if ($thismenu) {
            $this->assign('_gxcms_admin_selectedmenu', $thismenu); //后台主菜单

            $childitems = $menu->cache(true)->where('parent_id=' . $thismenu['id'])->order('display_index')->select();
            $this->assign('_gxcms_left_menu', $childitems); //页面左侧菜单
        }

        //后台时间现实
        date_default_timezone_set('Asia/Shanghai');
        $now = getdate(time());
        $cur_wday = $now['wday'];
        $weekarray = array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
        $nowtime = date("Y年m月d日 $weekarray[$cur_wday]");
        $this->assign('_gxcms_admin_nowtime', $nowtime);
    }

}